-----------------------------------------------
create function get_whs_length(
)
returns int
begin
	return @length
end
-----------------------------------------------
create function get_whs_width(
)
returns int
begin
	return @width
end
-----------------------------------------------
create procedure fill_whs
begin
declare @cell int
declare @end int
set @cell = 1
set @end = [dbo].[get_whs_width]
  while (@cell < @end) 
  begin
    insert into [dbo].[warehouse]([place]) values (@cell)
    SET @cell = @cell + 1
  end
end
----------------------------------------------
create procedure clear_whs_exist_goods
begin
	delete from  [dbo].[warehouse]
	delete from [dbo].[goods] 
		where ([warehouse].[state] is not null)
end
----------------------------------------------
create procedure clear_history_empty_goods
begin 
		delete from  [dbo].[history]
	delete from [dbo].[goods] 
		where ([warehouse].[state] is null)
end
---------------------------------------------